//
//  KDDModelInfo.m
//  MengLiao
//
//  Created by xiuxin on 2022/7/15.
//  Copyright © 2022 ZHBen. All rights reserved.
//

#import "KDDModel.h"
#import <objc/runtime.h>
@implementation NSObject (KDataDriven)

- (NSString *)ddConfigID
{
    return objc_getAssociatedObject(self, _cmd);
}

- (void)setDdConfigID:(NSString *)ddConfigID
{
    objc_setAssociatedObject(self, @selector(ddConfigID), ddConfigID, OBJC_ASSOCIATION_COPY);
}

- (KDDViewType)ddViewType
{
    NSNumber * viewTypeValue = objc_getAssociatedObject(self, _cmd);
    if (viewTypeValue == nil)
    {
        return KDDViewTypeNone;
    }
    return (KDDViewType)[viewTypeValue unsignedIntegerValue];
}

- (void)setDdViewType:(KDDViewType)ddViewType
{
    objc_setAssociatedObject(self, @selector(ddViewType), @(ddViewType), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (BOOL)ddNoSuspend
{
    return [objc_getAssociatedObject(self, _cmd) boolValue];
}

- (void)setDdNoSuspend:(BOOL)ddNoSuspend
{
    objc_setAssociatedObject(self, @selector(ddNoSuspend), @(ddNoSuspend), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (NSValue *)ddSize
{
    return objc_getAssociatedObject(self, _cmd);
}

- (void)setDdSize:(NSValue *)ddSize
{
    objc_setAssociatedObject(self, @selector(ddSize), ddSize, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (NSString *)ddReuseID
{
    return objc_getAssociatedObject(self, _cmd);
}

- (void)setDdReuseID:(NSString *)ddReuseID
{
    objc_setAssociatedObject(self, @selector(ddReuseID), ddReuseID, OBJC_ASSOCIATION_COPY);
}

- (NSString *)ddDecorationID
{
    return objc_getAssociatedObject(self, _cmd);
}

- (void)setDdDecorationID:(NSString *)ddDecorationID
{
    objc_setAssociatedObject(self, @selector(ddDecorationID), ddDecorationID, OBJC_ASSOCIATION_COPY);
}

- (BOOL)ddEndDecoration
{
    return [objc_getAssociatedObject(self, _cmd) boolValue];
}

- (void)setDdEndDecoration:(BOOL)ddEndDecoration
{
    objc_setAssociatedObject(self, @selector(ddEndDecoration), @(ddEndDecoration), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

@end

@implementation KDDModel

- (instancetype)initWithModel:(NSObject *)model
{
    if (self = [super init])
    {
        _model = model;
    }
    return self;
}

+ (KDDModel *)model:(NSObject *)model configID:(NSString *)configID
{
    KDDModel * ddModel = [[KDDModel alloc] initWithModel:model];
    ddModel.ddConfigID = configID;
    return ddModel;
}

@end

//@interface KDDModelInfo : NSObject <NSCopying>
//
//@property (strong,nonatomic) NSNumber * height;
//
//@property (strong,nonatomic) NSValue * size;
//
//@property (strong,nonatomic) NSNumber * canDelete;
//
//@property (strong,nonatomic) NSNumber * canMove;
//
//@property (strong,nonatomic) NSNumber * indent;
//
//@property (strong,nonatomic) NSArray<NSString *> * leadingActionIDList;
//
//@property (strong,nonatomic) NSArray<NSString *> * trailingActionIDList;
//
//@end
//@implementation KDDModelInfo
//KNSCopyingImpl
//@end
